package cn.sdack.go.common.entities.users;

import cn.sdack.go.common.entities.BaseEntity;
import cn.sdack.go.common.entities.PermissionEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.hibernate.validator.constraints.Length;

/**
 * 前端菜单
 * @author sdack
 * @date 2024/1/10
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "menus",indexes = {

})
public class MenuEntity extends PermissionEntity {

    @NotNull(message = "ID - 必填",groups = {BaseEntity.Set.class})
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;


    @NonNull
    @NotNull(message = "路径 - 必填",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Length(min = 3,max = 250,message = "路径 - 长度不正确",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Column(length = 250, nullable = false)
    private String path;

    @NonNull
    @NotNull(message = "路由名称 - 必填",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Length(min = 3,max = 250,message = "路由名称 - 长度不正确",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Column(length = 250, nullable = false)
    private String name;

    @NonNull
    @NotNull(message = "菜单名称 - 必填",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Length(min = 3,max = 50,message = "菜单名称 - 长度不正确",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Column(length = 50, nullable = false)
    private String menuName;

    @NonNull
    @NotNull(message = "权限 - 必填",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Length(min = 3,max = 2000,message = "权限 - 长度不正确",groups = {BaseEntity.Add.class,BaseEntity.Set.class})
    @Column(length = 2000, nullable = false)
    private String roles;

    // 是否需要登录鉴权
    @NonNull
    @Builder.Default
    @Column(nullable = false)
    private Boolean requiresAuth = false;

    // 是否在左侧菜单中隐藏该项
    private Boolean hideInMenu;

    // 如果设置为true，标签将不会添加到tab-bar中
    private Boolean noAffix;

    // 排序路由菜单项。如果设置该值，值越高，越靠前
    private Integer sort;

}
